﻿'<REA Tool is a open source Tool for Get Linux a lightweight download client for Operating Systems.>
'    Copyright (C) <2011>  <Dev-fire>

'    This program is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 3 of the License, or
'    (at your option) any later version.

'    This program is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.

'    You should have received a copy of the GNU General Public License
'    along with this program.  If not, see <http://www.gnu.org/licenses/>.
'Main
Public Class Main
    Public Response As WebResponse = Nothing
    Public Request As WebRequest = Nothing
    Public OS_Image As Bitmap = New Bitmap(328, 224)
    Public OS_Icon_Image As Bitmap = New Bitmap(48, 48)
    Public OS_Image_String As String
    Public OS_Icon_Image_String As String
    Public Selected_OS As String
    Public About As String
    Public Version As String
    Public Website As String
    Public Desktop As String
    Public Origin As String
    Public Download_32 As String
    Public File_Size_32 As String
    Public Download_64 As String
    Public File_Size_64 As String
    Public HTML_Page_Blank As String
    Public Updated_OS_HTML_Blank As String
    Public OS_HTML_Blank As String
    Public HTML_Page As String = HTML.TextBox_HTML_Page.Text
    Public Updated_OS_HTML As String = HTML.TextBox_Updated_OS_HTML.Text
    Public OS_HTML As String = HTML.TextBox_OS_HTML.Text

    Public severdebuger As Integer = 0
    Public AutoComplete_Operating_Systems As New AutoCompleteStringCollection()
    'SetBytes
    Function SetBytes(ByVal Bytes As Double) As String
        SetBytes = Nothing
        If Bytes >= 1073741824 Then
            SetBytes = Format(Bytes / 1024 / 1024 / 1024, "#0.00") & " GB"
        ElseIf Bytes >= 1048576 Then
            SetBytes = Format(Bytes / 1024 / 1024, "#0.00") & " MB"
        ElseIf Bytes >= 1024 Then
            SetBytes = Format(Bytes / 1024, "#0.00") & " KB"
        ElseIf Bytes < 1024 Then
            SetBytes = Fix(Bytes) & " Bytes"
        End If
    End Function
    'OnLoad
    Private Sub AddOS_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            'Build Operating Systems List
            Data.Build_Operating_Systems_List()
            'Count Operating Systems
            Data.OS_Count()

            HTML_Page_Blank = HTML.TextBox_HTML_Page.Text

            Updated_OS_HTML_Blank = HTML.TextBox_Updated_OS_HTML.Text
            OS_HTML_Blank = HTML.TextBox_OS_HTML.Text
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
            End
        End Try
    End Sub
    '
    'TabPage "Add OS"
    '
    'Get OS Icon
    Private Sub PictureBox_OS_Icon_1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox_OS_Icon_1.Click
        OpenFileDialog_Get_Image.InitialDirectory = Application.StartupPath
        OpenFileDialog_Get_Image.Title = "Find OS Icon Image"
        OpenFileDialog_Get_Image.Filter = "All Images & Executables|*.bmp;*.jpg;*.jpeg;*.gif;*.png;*.ico;*.exe|BMP (*.bmp)|*.bmp|JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|GIF (*.gif)|*.gif|PNG (*.png)|*.png|ICON (*.ico)|*.ico|EXE (*.exe)|*.exe"
        OpenFileDialog_Get_Image.FileName = Nothing 'Clear
        If OpenFileDialog_Get_Image.ShowDialog = Windows.Forms.DialogResult.OK = True Then
            Try
                If OpenFileDialog_Get_Image.FileName.EndsWith(".exe") Then
                    PictureBox_OS_Icon_1.Image = Drawing.Icon.ExtractAssociatedIcon(OpenFileDialog_Get_Image.FileName).ToBitmap()
                Else
                    PictureBox_OS_Icon_1.ImageLocation = OpenFileDialog_Get_Image.FileName
                End If
            Catch Ex As Exception
                MsgBox(Ex.Message, MsgBoxStyle.Critical)
            End Try
        End If
    End Sub
    'Get OS Image
    Private Sub PictureBox_OS_Image_1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox_OS_Image_1.Click
        OpenFileDialog_Get_Image.InitialDirectory = Application.StartupPath
        OpenFileDialog_Get_Image.Title = "Find OS Image"
        OpenFileDialog_Get_Image.Filter = "All Images|*.bmp;*.jpg;*.jpeg;*.gif;*.png;*.ico|BMP (*.bmp)|*.bmp|JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|GIF (*.gif)|*.gif|PNG (*.png)|*.png|ICON (*.ico)|*.ico"
        OpenFileDialog_Get_Image.FileName = Nothing 'Clear
        If OpenFileDialog_Get_Image.ShowDialog = Windows.Forms.DialogResult.OK = True Then
            Try
                PictureBox_OS_Image_1.ImageLocation = OpenFileDialog_Get_Image.FileName
            Catch Ex As Exception
                MsgBox(Ex.Message, MsgBoxStyle.Critical)
            End Try
        End If
    End Sub
    'Get File Size
    Private Sub Button_Get_File_Size_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Get_File_Sizes.Click
        Try
            If TextBox_Download_32_Bit_1.TextLength > 0 Or TextBox_Download_64_Bit_1.TextLength > 0 Then
                NotifyIcon_Main.BalloonTipText = "Requesting File Sizes."
                NotifyIcon_Main.ShowBalloonTip(5000)
                TextBox_File_Size_32_Bit_2.Clear()
                TextBox_File_Size_64_Bit_2.Clear()
                Me.Hide()
                If TextBox_Download_32_Bit_1.TextLength > 0 Then
                    If TextBox_Download_32_Bit_1.Text.Contains("://") Then
                        If TextBox_Download_32_Bit_1.Text.StartsWith("http://") Or TextBox_Download_32_Bit_1.Text.StartsWith("https://") Then
                            TextBox_File_Size_32_Bit_1.Clear()
                            Request = WebRequest.Create(TextBox_Download_32_Bit_1.Text)
                            Request.Proxy = Nothing
                            'If required by the server, set the credentials.
                            Request.Credentials = CredentialCache.DefaultCredentials
                            Request.Timeout = 14 * 1000
                            Response = Request.GetResponse
                            Response.Close()
                            TextBox_File_Size_32_Bit_1.Text = SetBytes(Response.ContentLength).ToString
                        End If
                    Else
                        MsgBox("Download 32 Bit URL invalid, Please enter a vailed url", MsgBoxStyle.Information)
                    End If
                    NotifyIcon_Main.BalloonTipText = "File Size 32Bit Received."
                    NotifyIcon_Main.ShowBalloonTip(5000)
                End If
                '
                If TextBox_Download_64_Bit_1.TextLength > 0 Then
                    If TextBox_Download_64_Bit_1.Text.Contains("://") Then
                        If TextBox_Download_64_Bit_1.Text.StartsWith("http://") Or TextBox_Download_64_Bit_1.Text.StartsWith("https://") Then
                            TextBox_File_Size_64_Bit_1.Clear()
                            Request = WebRequest.Create(TextBox_Download_64_Bit_1.Text)
                            Request.Proxy = Nothing
                            'If required by the server, set the credentials.
                            Request.Credentials = CredentialCache.DefaultCredentials
                            Request.Timeout = 14 * 1000
                            Response = Request.GetResponse
                            Response.Close()
                            TextBox_File_Size_64_Bit_1.Text = SetBytes(Response.ContentLength).ToString
                        End If
                    Else
                        MsgBox("Download 64 Bit URL invalid, Please enter a vailed url", MsgBoxStyle.Information)
                    End If
                    NotifyIcon_Main.BalloonTipText = "File Size 64Bit Received."
                    NotifyIcon_Main.ShowBalloonTip(5000)
                End If
            End If
            Me.Show()
        Catch Wx As System.Net.WebException
            Me.Show()
            MsgBox(Wx.Message, MsgBoxStyle.Information)
        Catch Ex As Exception
            Me.Show()
            MsgBox(Ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub
    'Add OS
    Private Sub Button_Add_OS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Add_OS.Click
        Try
            'OS Title
            If TextBox_OS_Title_1.Text = Nothing Then
                MsgBox("Please enter a OS Title.", MsgBoxStyle.Information)
                Exit Sub
            Else
                Dim invalidChars() As String = {"\", "/", ":", "*", "?", Chr(34), "<", ">", "|"}
                For Each i In invalidChars
                    If TextBox_OS_Title_1.Text.Contains(i) Then
                        MsgBox("OS Title contains invalid characters", MsgBoxStyle.Information)
                        Exit Sub
                    End If
                Next
                'About
                If TextBox_About_1.Text = Nothing Then
                    MsgBox("Please enter a About.", MsgBoxStyle.Information)
                    Exit Sub
                Else
                    'Origin
                    If TextBox_Origin_1.Text = Nothing Then
                        MsgBox("Please enter a Origin.", MsgBoxStyle.Information)
                        Exit Sub
                    Else
                        'Version
                        If TextBox_Version_1.Text = Nothing Then
                            MsgBox("Please enter a Version.", MsgBoxStyle.Information)
                            Exit Sub
                        Else
                            'Desktop
                            If TextBox_Desktop_1.Text = Nothing Then
                                MsgBox("Please enter a Desktop.", MsgBoxStyle.Information)
                                Exit Sub
                            Else
                                'Website URL
                                If TextBox_Website_1.Text = Nothing Then
                                    MsgBox("Please enter a Website URL.", MsgBoxStyle.Information)
                                    Exit Sub
                                Else
                                    'Website URL
                                    If Not TextBox_Website_1.Text.Contains("://") Then
                                        MsgBox("Website URL invalid, Please enter a vailed url", MsgBoxStyle.Information)
                                        Exit Sub
                                    Else
                                        'Download URLs / No Text
                                        If TextBox_Download_32_Bit_1.Text = Nothing And TextBox_Download_64_Bit_1.Text = Nothing Then
                                            MsgBox("Please enter the Download URLs.", MsgBoxStyle.Information)
                                            Exit Sub
                                        Else
                                            'Download URLs / Invailed URLs
                                            If Not TextBox_Download_32_Bit_1.Text.Contains("://") And Not TextBox_Download_64_Bit_1.Text.Contains("://") Then
                                                MsgBox("Download URL invalid, Please enter a vailed url", MsgBoxStyle.Information)
                                                Exit Sub
                                            Else
                                                'File Size
                                                If TextBox_File_Size_32_Bit_1.Text = Nothing And TextBox_File_Size_64_Bit_1.Text = Nothing Then
                                                    MsgBox("Please get the File Sizes.", MsgBoxStyle.Information)
                                                    Exit Sub
                                                Else
                                                    'Check PictureBox1 for Blank
                                                    If PictureBox_OS_Icon_1.Image Is Nothing Then
                                                        MsgBox("Please select a image for OS Icon", MsgBoxStyle.Information)
                                                        Exit Sub
                                                    Else
                                                        'Check PictureBox_OS_Image for Blank
                                                        If PictureBox_OS_Image_1.Image Is Nothing Then
                                                            MsgBox("Please select a image for OS Image", MsgBoxStyle.Information)
                                                            Exit Sub
                                                        Else
                                                            If TextBox_Download_32_Bit_1.Text = Nothing Or TextBox_Download_64_Bit_1.Text = Nothing Then
                                                                If MessageBox.Show("Are you sure there is not two assembly version for this OS ? ", "REA Tool", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.No Then
                                                                End If
                                                            End If
                                                            Data.Build_HTML_Page_1()
                                                            Data.Save_HTML_1()
                                                            'Add The OS
                                                            Dim OS_Image_Graphics As Graphics = Graphics.FromImage(OS_Image)
                                                            OS_Image_Graphics.DrawImage(PictureBox_OS_Image_1.Image, 0, 0, OS_Image.Width, OS_Image.Height)
                                                            Dim Icon_Image_Graphics As Graphics = Graphics.FromImage(OS_Icon_Image)
                                                            Icon_Image_Graphics.DrawImage(PictureBox_OS_Icon_1.Image, 0, 0, OS_Icon_Image.Width, OS_Icon_Image.Height)
                                                            Data.Add_OS()
                                                            'Clear All For Next OS To Be Added
                                                            TextBox_OS_Title_1.Clear()
                                                            TextBox_Version_1.Clear()
                                                            TextBox_File_Size_32_Bit_1.Clear()
                                                            TextBox_File_Size_64_Bit_1.Clear()
                                                            TextBox_About_1.Clear()
                                                            TextBox_Website_1.Clear()
                                                            TextBox_Origin_1.Clear()
                                                            TextBox_Desktop_1.Clear()
                                                            TextBox_Download_32_Bit_1.Clear()
                                                            TextBox_Download_64_Bit_1.Clear()
                                                            PictureBox_OS_Icon_1.Image = Nothing
                                                            PictureBox_OS_Image_1.Image = Nothing
                                                            'Dispose Drawing
                                                            OS_Image_Graphics.Dispose()
                                                            Icon_Image_Graphics.Dispose()
                                                            'Renew Bitmaps
                                                            OS_Image = New Bitmap(328, 224)
                                                            OS_Icon_Image = New Bitmap(48, 48)
                                                            'OS HTML Page
                                                            Data.Save_HTML_2()
                                                            'Clear All For Next Game To Be Added
                                                            ListBox_Operating_Systems_1.SelectedIndex = -1
                                                        End If
                                                    End If
                                                End If
                                            End If
                                        End If
                                    End If
                                End If
                            End If
                        End If
                    End If
                End If
            End If
        Catch Ex As Exception
            MsgBox(Ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub

    '
    'TabPage "Remove OS"
    '
    'Remove OS
    Private Sub Button_Remove_OS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Remove_OS.Click
        If Not ListBox_Operating_Systems_1.SelectedIndex = -1 Then
            Data.Remove_OS()
        End If
    End Sub

    '
    'TabPage "Edit OS"
    '
    'Selected Operating System Changed
    Private Sub ListBox_Operating_Systems_2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox_Operating_Systems_2.SelectedIndexChanged
        If Not ListBox_Operating_Systems_2.SelectedIndex = -1 Then 'Check for a selected OS
            If Not Selected_OS = ListBox_Operating_Systems_2.SelectedItem.ToString Then
                Try
                    HTML.SaveHTMLPageToolStripMenuItem.Enabled = True
                    HTML.CopyUpdatedGameHTMLToolStripMenuItem.Enabled = True
                    HTML.CopyGamesHTMLToolStripMenuItem.Enabled = True
                    'Clear GUI And Data
                    Data.Clear_GUI_And_Data()
                    Selected_OS = ListBox_Operating_Systems_2.SelectedItem.ToString
                    TextBox_OS_Title_2.Text = Selected_OS
                    'Set Images
                    PictureBox_OS_Icon_2.ImageLocation = (Application.StartupPath & "/Data/Operating Systems/" & ListBox_Operating_Systems_2.SelectedItem.ToString & "/Icon.png")
                    OS_Icon_Image_String = PictureBox_OS_Icon_2.ImageLocation
                    PictureBox_OS_Image_2.ImageLocation = (Application.StartupPath & "/Data/Operating Systems/" & ListBox_Operating_Systems_2.SelectedItem.ToString & "/Image.jpg")
                    OS_Image_String = PictureBox_OS_Image_2.ImageLocation
                    'Read Stream
                    Dim OS_Reader As New StreamReader(Application.StartupPath & "/Data/Operating Systems/" & ListBox_Operating_Systems_2.SelectedItem.ToString & "/OS.cfg")
                    Dim CFG_Line() As String = Split(OS_Reader.ReadToEnd, vbCrLf.ToCharArray)
                    OS_Reader.Close() 'Close StreamReader
                    'About //Line 0
                    If CFG_Line(0).StartsWith("About:") Then
                        CFG_Line(0) = CFG_Line(0).Substring(6)
                        If Not CFG_Line(0) = Nothing Then
                            TextBox_About_2.Text = CFG_Line(0).ToString
                            About = CFG_Line(0).ToString
                        End If
                    End If
                    'Origin //Line 1
                    If CFG_Line(1).StartsWith("Origin:") Then
                        CFG_Line(1) = CFG_Line(1).Substring(7)
                        If Not CFG_Line(1) = Nothing Then
                            TextBox_Origin_2.Text = CFG_Line(1).ToString
                            Origin = CFG_Line(1).ToString
                        End If
                    End If
                    'Version //Line 2
                    If CFG_Line(2).StartsWith("Version:") Then
                        CFG_Line(2) = CFG_Line(2).Substring(8)
                        If Not CFG_Line(2) = Nothing Then
                            TextBox_Version_2.Text = CFG_Line(2).ToString
                            Version = CFG_Line(2).ToString
                        End If
                    End If
                    'Desktop //Line 3
                    If CFG_Line(3).StartsWith("Desktop:") Then
                        CFG_Line(3) = CFG_Line(3).Substring(8)
                        If Not CFG_Line(3) = Nothing Then
                            TextBox_Desktop_2.Text = CFG_Line(3).ToString
                            Desktop = CFG_Line(3).ToString
                        End If
                    End If
                    'Website //Line 4
                    If CFG_Line(4).StartsWith("Website:") Then
                        CFG_Line(4) = CFG_Line(4).Substring(8)
                        If CFG_Line(4).StartsWith("http://") Or CFG_Line(4).StartsWith("https://") Then
                            TextBox_Website_2.Text = CFG_Line(4).ToString
                            Website = CFG_Line(4).ToString
                        End If
                    End If
                    'Download_32 //Line 5
                    If CFG_Line(5).StartsWith("Download_32:") Then
                        CFG_Line(5) = CFG_Line(5).Substring(12)
                        If CFG_Line(5).StartsWith("http://") Or CFG_Line(5).StartsWith("https://") Then
                            TextBox_Download_32_Bit_2.Text = CFG_Line(5).ToString
                            Download_32 = CFG_Line(5).ToString
                        End If
                    End If
                    'FileSize_32 //Line 6
                    If CFG_Line(6).StartsWith("FileSize_32:") Then
                        CFG_Line(6) = CFG_Line(6).Substring(12)
                        If Not CFG_Line(6) = Nothing Then
                            TextBox_File_Size_32_Bit_2.Text = CFG_Line(6).ToString
                            File_Size_32 = CFG_Line(6).ToString
                        End If
                    End If
                    'Download_64 //Line 7
                    If CFG_Line(7).StartsWith("Download_64:") Then
                        CFG_Line(7) = CFG_Line(7).Substring(12)
                        If CFG_Line(7).StartsWith("http://") Or CFG_Line(7).StartsWith("https://") Then
                            TextBox_Download_64_Bit_2.Text = CFG_Line(7).ToString
                            Download_64 = CFG_Line(7).ToString
                        End If
                    End If
                    'FileSize_64 //Line 8
                    If CFG_Line(8).StartsWith("FileSize_64:") Then
                        CFG_Line(8) = CFG_Line(8).Substring(12)
                        If Not CFG_Line(8) = Nothing Then
                            TextBox_File_Size_64_Bit_2.Text = CFG_Line(8).ToString
                            File_Size_64 = CFG_Line(8).ToString
                        End If
                    End If

                    Data.Build_HTML_Page_2()
                    Data.Build_Updated_OS_HTML()
                    Data.Build_OS_HTML()

                    'Clear array
                    CFG_Line = Nothing
                Catch Wx As System.Net.WebException
                    MsgBox(Wx.Message, MsgBoxStyle.Information)
                Catch Ex As Exception
                    MsgBox(Ex.Message)
                End Try
            End If
        Else
            HTML.SaveHTMLPageToolStripMenuItem.Enabled = False
            HTML.CopyUpdatedGameHTMLToolStripMenuItem.Enabled = False
            HTML.CopyGamesHTMLToolStripMenuItem.Enabled = False
            Selected_OS = Nothing
            Data.Clear_GUI_And_Data()
            HTML.TextBox_HTML_Page.Text = HTML_Page_Blank
            HTML.TextBox_Updated_OS_HTML.Text = Updated_OS_HTML_Blank
            HTML.TextBox_OS_HTML.Text = OS_HTML_Blank
        End If
    End Sub
    'Change File Sizes
    Private Sub Button_Change_File_Sizes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Change_File_Sizes.Click
        Try
            If TextBox_Download_32_Bit_2.TextLength > 0 Or TextBox_Download_64_Bit_2.TextLength > 0 Then
                NotifyIcon_Main.BalloonTipText = "Requesting File Sizes."
                NotifyIcon_Main.ShowBalloonTip(5000)
                TextBox_File_Size_32_Bit_2.Clear()
                TextBox_File_Size_64_Bit_2.Clear()
                Me.Hide()
                If TextBox_Download_32_Bit_2.TextLength > 0 Then
                    If TextBox_Download_32_Bit_2.Text.Contains("://") Then
                        If TextBox_Download_32_Bit_2.Text.StartsWith("http://") Or TextBox_Download_32_Bit_2.Text.StartsWith("https://") Then
                            TextBox_File_Size_32_Bit_2.Clear()
                            Request = WebRequest.Create(TextBox_Download_32_Bit_2.Text)
                            Request.Proxy = Nothing
                            'If required by the server, set the credentials.
                            Request.Credentials = CredentialCache.DefaultCredentials
                            Request.Timeout = 14 * 1000
                            Response = Request.GetResponse
                            Response.Close()
                            TextBox_File_Size_32_Bit_2.Text = SetBytes(Response.ContentLength).ToString
                        End If
                    Else
                        MsgBox("Download 32 Bit URL invalid, Please enter a vailed url", MsgBoxStyle.Information)
                    End If
                    NotifyIcon_Main.BalloonTipText = "File Size 32Bit Received."
                    NotifyIcon_Main.ShowBalloonTip(5000)
                    If TextBox_File_Size_32_Bit_2.Text = File_Size_32 Then
                        TextBox_File_Size_32_Bit_2.ForeColor = Color.Black
                    Else
                        TextBox_File_Size_32_Bit_2.ForeColor = Color.Red
                    End If
                End If
                If TextBox_Download_64_Bit_2.TextLength > 0 Then
                    If TextBox_Download_64_Bit_2.Text.Contains("://") Then
                        If TextBox_Download_64_Bit_2.Text.StartsWith("http://") Or TextBox_Download_64_Bit_2.Text.StartsWith("https://") Then
                            TextBox_File_Size_64_Bit_2.Clear()
                            Request = WebRequest.Create(TextBox_Download_64_Bit_2.Text)
                            Request.Proxy = Nothing
                            'If required by the server, set the credentials.
                            Request.Credentials = CredentialCache.DefaultCredentials
                            Request.Timeout = 14 * 1000
                            Response = Request.GetResponse
                            Response.Close()
                            TextBox_File_Size_64_Bit_2.Text = SetBytes(Response.ContentLength).ToString
                        End If
                    Else
                        MsgBox("Download 64 Bit URL invalid, Please enter a vailed url", MsgBoxStyle.Information)
                    End If
                    NotifyIcon_Main.BalloonTipText = "File Size 64Bit Received."
                    NotifyIcon_Main.ShowBalloonTip(5000)
                    If TextBox_File_Size_64_Bit_2.Text = File_Size_64 Then
                        TextBox_File_Size_64_Bit_2.ForeColor = Color.Black
                    Else
                        TextBox_File_Size_64_Bit_2.ForeColor = Color.Red
                    End If
                End If
            End If
            Me.Show()
        Catch Wx As System.Net.WebException
            Me.Show()
            MsgBox(Wx.Message, MsgBoxStyle.Information)
        Catch Ex As Exception
            Me.Show()
            MsgBox(Ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub
    'Edit OS
    Private Sub Button_Edit_OS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Edit_OS.Click
        If Not ListBox_Operating_Systems_2.SelectedIndex = -1 Then
            Try
                'OS Title
                If TextBox_OS_Title_2.Text = Nothing Then
                    MsgBox("Please enter a OS Title.", MsgBoxStyle.Information)
                    Exit Sub
                Else
                    Dim invalidChars() As String = {"\", "/", ":", "*", "?", Chr(34), "<", ">", "|"}
                    For Each i In invalidChars
                        If TextBox_OS_Title_2.Text.Contains(i) Then
                            MsgBox("OS Title contains invalid characters", MsgBoxStyle.Information)
                            Exit Sub
                        End If
                    Next
                    'About
                    If TextBox_About_2.Text = Nothing Then
                        MsgBox("Please enter a About.", MsgBoxStyle.Information)
                        Exit Sub
                    Else
                        'Origin
                        If TextBox_Origin_2.Text = Nothing Then
                            MsgBox("Please enter a Origin.", MsgBoxStyle.Information)
                            Exit Sub
                        Else
                            'Version
                            If TextBox_Version_2.Text = Nothing Then
                                MsgBox("Please enter a Version.", MsgBoxStyle.Information)
                                Exit Sub
                            Else
                                'Desktop
                                If TextBox_Desktop_2.Text = Nothing Then
                                    MsgBox("Please enter a Desktop.", MsgBoxStyle.Information)
                                    Exit Sub
                                Else
                                    'Website URL
                                    If TextBox_Website_2.Text = Nothing Then
                                        MsgBox("Please enter a Website URL.", MsgBoxStyle.Information)
                                        Exit Sub
                                    Else
                                        'Website URL
                                        If Not TextBox_Website_2.Text.Contains("://") Then
                                            MsgBox("Website URL invalid, Please enter a vailed url.", MsgBoxStyle.Information)
                                            Exit Sub
                                        Else
                                            'Download URLs / No Text
                                            If TextBox_Download_32_Bit_2.Text = Nothing And TextBox_Download_64_Bit_2.Text = Nothing Then
                                                MsgBox("Please enter the Download URLs.", MsgBoxStyle.Information)
                                                Exit Sub
                                            Else
                                                'Download URLs / Invailed URLs
                                                If Not TextBox_Download_32_Bit_2.Text.Contains("://") And Not TextBox_Download_64_Bit_2.Text.Contains("://") Then
                                                    MsgBox("Download URL invalid, Please enter a vailed url.", MsgBoxStyle.Information)
                                                    Exit Sub
                                                Else
                                                    'File Size
                                                    If TextBox_File_Size_32_Bit_2.Text = Nothing And TextBox_File_Size_64_Bit_2.Text = Nothing Then
                                                        MsgBox("Please get the File Sizes.", MsgBoxStyle.Information)
                                                        Exit Sub
                                                    Else
                                                        'Check PictureBox1 for Blank
                                                        If PictureBox_OS_Icon_2.Image Is Nothing Then
                                                            MsgBox("Please select a image for OS Icon.", MsgBoxStyle.Information)
                                                            Exit Sub
                                                        Else
                                                            'Check PictureBox OS Image for Blank
                                                            If PictureBox_OS_Image_2.Image Is Nothing Then
                                                                MsgBox("Please select a image for OS Image.", MsgBoxStyle.Information)
                                                                Exit Sub
                                                            Else
                                                                'If Nothing Has Been Changed
                                                                If Selected_OS = TextBox_OS_Title_2.Text And About = TextBox_About_2.Text And Website = TextBox_Website_2.Text And Desktop = TextBox_Desktop_2.Text And Origin = TextBox_Origin_2.Text And Version = TextBox_Version_2.Text _
                                                                And Download_32 = TextBox_Download_32_Bit_2.Text And Download_64 = TextBox_Download_64_Bit_2.Text And File_Size_32 = TextBox_File_Size_32_Bit_2.Text _
                                                                And File_Size_64 = TextBox_File_Size_64_Bit_2.Text And PictureBox_OS_Icon_2.ImageLocation = OS_Icon_Image_String And PictureBox_OS_Image_2.ImageLocation = OS_Image_String Then
                                                                    MsgBox("Please edit some information first.", MsgBoxStyle.Information)
                                                                Else
                                                                    Dim Changes As New System.Text.StringBuilder()
                                                                    'OS Title
                                                                    If Not Selected_OS = TextBox_OS_Title_2.Text Then
                                                                        Changes.Append("(OS Title)" & vbNewLine)
                                                                    End If
                                                                    'About
                                                                    If Not About = TextBox_About_2.Text Then
                                                                        Changes.Append("(About)" & vbNewLine)
                                                                    End If
                                                                    'Website
                                                                    If Not Website = TextBox_Website_2.Text Then
                                                                        Changes.Append("(Website)" & vbNewLine)
                                                                    End If
                                                                    'Desktop
                                                                    If Not Desktop = TextBox_Desktop_2.Text Then
                                                                        Changes.Append("(Desktop)" & vbNewLine)
                                                                    End If
                                                                    'Origin
                                                                    If Not Origin = TextBox_Origin_2.Text Then
                                                                        Changes.Append("(Origin)" & vbNewLine)
                                                                    End If
                                                                    'Version
                                                                    If Not Version = TextBox_Version_2.Text Then
                                                                        Changes.Append("(Version)" & vbNewLine)
                                                                    Else
                                                                        If Download_32 = TextBox_Download_32_Bit_2.Text Or Download_64 = TextBox_Download_64_Bit_2.Text _
                                                                        Or File_Size_32 = TextBox_File_Size_32_Bit_2.Text Or File_Size_64 = TextBox_File_Size_64_Bit_2.Text Then
                                                                            Changes.Append("Note: (Version) has not changed!" & vbNewLine)
                                                                        End If
                                                                    End If
                                                                    'Download 32
                                                                    If Not Download_32 = TextBox_Download_32_Bit_2.Text Then
                                                                        If Not File_Size_32 = TextBox_File_Size_32_Bit_2.Text Then
                                                                            Changes.Append("(Download 32)" & vbNewLine)
                                                                        Else
                                                                            Changes.Append("(Download 32) *Note: File Size 32 has not changed!" & vbNewLine)
                                                                        End If
                                                                    End If
                                                                    'File Size 32
                                                                    If Not File_Size_32 = TextBox_File_Size_32_Bit_2.Text Then
                                                                        Changes.Append("(File Size 32)" & vbNewLine)
                                                                    End If
                                                                    'Download 64
                                                                    If Not Download_64 = TextBox_Download_64_Bit_2.Text Then
                                                                        If Not File_Size_64 = TextBox_File_Size_64_Bit_2.Text Then
                                                                            Changes.Append("(Download 64)" & vbNewLine)
                                                                        Else
                                                                            Changes.Append("(Download 64) *Note: File Size 64 has not changed!" & vbNewLine)
                                                                        End If
                                                                    End If
                                                                    'File Size 64
                                                                    If Not File_Size_64 = TextBox_File_Size_64_Bit_2.Text Then
                                                                        Changes.Append("(File Size 64)" & vbNewLine)
                                                                    End If
                                                                    'OS Icon
                                                                    If Not PictureBox_OS_Icon_2.ImageLocation = OS_Icon_Image_String Then
                                                                        Changes.Append("(OS Icon)" & vbNewLine)
                                                                    End If
                                                                    'OS Image
                                                                    If Not PictureBox_OS_Image_2.ImageLocation = OS_Image_String Then
                                                                        Changes.Append("(OS Image)" & vbNewLine)
                                                                    End If
                                                                    'Edit Message
                                                                    If MessageBox.Show("The following information has been edited." & vbNewLine & Changes.ToString & "Are you sure you are done editing?", "REA Tool", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.No Then
                                                                        Exit Sub
                                                                    End If
                                                                    'Add The OS
                                                                    If Not PictureBox_OS_Icon_2.ImageLocation = OS_Icon_Image_String Then
                                                                        Dim Icon_Image_Graphics As Graphics = Graphics.FromImage(OS_Icon_Image)
                                                                        Icon_Image_Graphics.DrawImage(PictureBox_OS_Icon_2.Image, 0, 0, OS_Icon_Image.Width, OS_Icon_Image.Height)
                                                                        'Dispose Drawing
                                                                        Icon_Image_Graphics.Dispose()
                                                                    End If
                                                                    If Not PictureBox_OS_Image_2.ImageLocation = OS_Image_String Then
                                                                        Dim OS_Image_Graphics As Graphics = Graphics.FromImage(OS_Image)
                                                                        OS_Image_Graphics.DrawImage(PictureBox_OS_Image_2.Image, 0, 0, OS_Image.Width, OS_Image.Height)
                                                                        'Dispose Drawing
                                                                        OS_Image_Graphics.Dispose()
                                                                    End If
                                                                    Data.Edit_OS()
                                                                    'Renew Bitmaps
                                                                    If Not PictureBox_OS_Icon_2.ImageLocation = OS_Icon_Image_String Then
                                                                        OS_Icon_Image = New Bitmap(48, 48)
                                                                    End If
                                                                    If Not PictureBox_OS_Image_2.ImageLocation = OS_Image_String Then
                                                                        OS_Image = New Bitmap(328, 224)
                                                                    End If
                                                                    'Clear All For Next OS To Be Added
                                                                    ListBox_Operating_Systems_2.SelectedIndex = -1
                                                                End If
                                                            End If
                                                        End If
                                                    End If
                                                End If
                                            End If
                                        End If
                                    End If
                                End If
                            End If
                        End If
                    End If
                End If
            Catch Ex As Exception
                MsgBox(Ex.Message, MsgBoxStyle.Critical)
            End Try
        End If
    End Sub
    'Change OS Icon
    Private Sub PictureBox_OS_Icon_2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox_OS_Icon_2.Click
        OpenFileDialog_Get_Image.InitialDirectory = Application.StartupPath
        OpenFileDialog_Get_Image.Title = "Find OS Icon Image"
        OpenFileDialog_Get_Image.Filter = "All Images & Executables|*.bmp;*.jpg;*.jpeg;*.gif;*.png;*.ico;*.exe|BMP (*.bmp)|*.bmp|JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|GIF (*.gif)|*.gif|PNG (*.png)|*.png|ICON (*.ico)|*.ico|EXE (*.exe)|*.exe"
        OpenFileDialog_Get_Image.FileName = Nothing 'Clear
        If OpenFileDialog_Get_Image.ShowDialog = Windows.Forms.DialogResult.OK = True Then
            Try
                If OpenFileDialog_Get_Image.FileName.EndsWith(".exe") Then
                    PictureBox_OS_Icon_2.Image = Drawing.Icon.ExtractAssociatedIcon(OpenFileDialog_Get_Image.FileName).ToBitmap()
                Else
                    PictureBox_OS_Icon_2.ImageLocation = OpenFileDialog_Get_Image.FileName
                End If
            Catch Ex As Exception
                MsgBox(Ex.Message, MsgBoxStyle.Critical)
            End Try
        End If
    End Sub
    'Change OS Image
    Private Sub PictureBox_OS_Image_2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox_OS_Image_2.Click
        OpenFileDialog_Get_Image.InitialDirectory = Application.StartupPath
        OpenFileDialog_Get_Image.Title = "Find OS Image"
        OpenFileDialog_Get_Image.Filter = "All Images|*.bmp;*.jpg;*.jpeg;*.gif;*.png;*.ico|BMP (*.bmp)|*.bmp|JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|GIF (*.gif)|*.gif|PNG (*.png)|*.png|ICON (*.ico)|*.ico"
        OpenFileDialog_Get_Image.FileName = Nothing 'Clear
        If OpenFileDialog_Get_Image.ShowDialog = Windows.Forms.DialogResult.OK = True Then
            Try
                PictureBox_OS_Image_2.ImageLocation = OpenFileDialog_Get_Image.FileName
            Catch Ex As Exception
                MsgBox(Ex.Message, MsgBoxStyle.Critical)
            End Try
        End If
    End Sub
    'Show/Hide Main Window
    Private Sub NotifyIcon_Main_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon_Main.MouseClick
        If e.Button = Windows.Forms.MouseButtons.Left Then
            Data.Show_Hide_Main_Window()
        End If
    End Sub
    'Visit Websit
    Private Sub Button_Visit_Websit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Visit_Website.Click
        If Not ListBox_Operating_Systems_2.SelectedIndex = -1 Then
            Try
                Process.Start(Website)
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Critical)
            End Try
        End If
    End Sub
    'OS Title 2 Leave
    Private Sub TextBox_OS_Title_2_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox_OS_Title_2.Leave
        If TextBox_OS_Title_2.Text = Selected_OS Then
            TextBox_OS_Title_2.ForeColor = Color.Black
        Else
            TextBox_OS_Title_2.ForeColor = Color.Red
        End If
    End Sub
    'Version 2 Leave
    Private Sub TextBox_Version_2_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox_Version_2.Leave
        If TextBox_Version_2.Text = Version Then
            TextBox_Version_2.ForeColor = Color.Black
        Else
            TextBox_Version_2.ForeColor = Color.Red
        End If
    End Sub
    'Desktop 2 Leave
    Private Sub TextBox_Desktop_2_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox_Desktop_2.Leave
        If TextBox_Desktop_2.Text = Desktop Then
            TextBox_Desktop_2.ForeColor = Color.Black
        Else
            TextBox_Desktop_2.ForeColor = Color.Red
        End If
    End Sub
    'Origin 2 Leave
    Private Sub TextBox_Origin_2_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox_Origin_2.Leave
        If TextBox_Origin_2.Text = Origin Then
            TextBox_Origin_2.ForeColor = Color.Black
        Else
            TextBox_Origin_2.ForeColor = Color.Red
        End If
    End Sub
    'About 2 Leave
    Private Sub TextBox_About_2_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox_About_2.Leave
        If TextBox_About_2.Text = About Then
            TextBox_About_2.ForeColor = Color.Black
        Else
            TextBox_About_2.ForeColor = Color.Red
        End If
    End Sub
    'Website 2 Leave
    Private Sub TextBox_Website_2_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox_Website_2.Leave
        If TextBox_Website_2.Text = Website Then
            TextBox_Website_2.ForeColor = Color.Black
        Else
            TextBox_Website_2.ForeColor = Color.Red
        End If
    End Sub
    'Download 32 Bit 2 Leave
    Private Sub TextBox_Download_32_Bit_2_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox_Download_32_Bit_2.Leave
        If TextBox_Download_32_Bit_2.Text = Download_32 Then
            TextBox_Download_32_Bit_2.ForeColor = Color.Black
        Else
            TextBox_Download_32_Bit_2.ForeColor = Color.Red
        End If
    End Sub
    'Download 64 Bit 2 Leave
    Private Sub TextBox_Download_64_Bit_2_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox_Download_64_Bit_2.Leave
        If TextBox_Download_64_Bit_2.Text = Download_64 Then
            TextBox_Download_64_Bit_2.ForeColor = Color.Black
        Else
            TextBox_Download_64_Bit_2.ForeColor = Color.Red
        End If
    End Sub
    'ListBox_Operating_Systems_2 KeyDown
    Private Sub ListBox_Operating_Systems_2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListBox_Operating_Systems_2.KeyDown
        'F2 Change File Size
        If e.KeyCode = Keys.F2 And TabControl_Main.SelectedTab.Text = "Edit OS" Then
            Button_Change_File_Sizes.PerformClick()
        End If

        'F3 Create All html pages
        If e.KeyCode = Keys.F3 Then
            If Not ListBox_Operating_Systems_2.SelectedIndex = -1 Then
                For OS As Integer = 0 To ListBox_Operating_Systems_2.Items.Count - 1
                    ListBox_Operating_Systems_2.SetSelected(OS, True)
                    If File.Exists(Application.StartupPath & "/Source/Website/operating_systems/" & TextBox_OS_Title_2.Text & ".html") Then
                        File.Delete(Application.StartupPath & "/Source/Website/operating_systems/" & TextBox_OS_Title_2.Text & ".html")
                    End If
                    My.Computer.FileSystem.WriteAllText(Application.StartupPath & "/Source/Website/operating_systems/" & TextBox_OS_Title_2.Text & ".html", HTML.TextBox_HTML_Page.Text, True)
                    NotifyIcon_Main.BalloonTipText = "File: " & TextBox_OS_Title_2.Text & ".html" & " Saved"
                    NotifyIcon_Main.ShowBalloonTip(1500)
                    NotifyIcon_Main.BalloonTipText = Nothing
                Next

            End If
        End If

        'F1 Check All Download Files
        Try
            If e.KeyCode = Keys.F1 And Not Scan.Visible Then
                Me.Hide()
                severdebuger = 0
                NotifyIcon1.Visible = True
                NotifyIcon_Main.Visible = False
                For os As Integer = 0 To ListBox_Operating_Systems_2.Items.Count - 1
                    ListBox_Operating_Systems_2.SetSelected(os, True)
                    Scan.Text = "Scaned: " & os + 1 & "/" & ListBox_Operating_Systems_2.Items.Count & " Servers"
                    NotifyIcon1.BalloonTipText = "Scaned: " & os + 1 & "/" & ListBox_Operating_Systems_2.Items.Count & " Servers"
                    NotifyIcon1.ShowBalloonTip(14000)
                    Try
                        If TextBox_Download_32_Bit_2.TextLength > 0 Or TextBox_Download_64_Bit_2.TextLength > 0 Then
                            If TextBox_Download_32_Bit_2.TextLength > 0 Then
                                If TextBox_Download_32_Bit_2.Text.Contains("://") Then
                                    If TextBox_Download_32_Bit_2.Text.StartsWith("http://") Or TextBox_Download_32_Bit_2.Text.StartsWith("https://") Then
                                        Request = WebRequest.Create(TextBox_Download_32_Bit_2.Text)
                                        Request.Proxy = Nothing
                                        'If required by the server, set the credentials.
                                        Request.Credentials = CredentialCache.DefaultCredentials
                                        Request.Timeout = 14000
                                        Response = Request.GetResponse
                                        Response.Close()
                                        If Not TextBox_File_Size_32_Bit_2.Text = File_Size_32 Then
                                            Scan.TextBox_Files.AppendText(ListBox_Operating_Systems_2.SelectedItem.ToString & " (File Size Changed)" & vbNewLine)
                                        End If

                                    End If
                                Else
                                    Scan.TextBox_Files.AppendText(ListBox_Operating_Systems_2.SelectedItem.ToString & " (Download 32 Bit URL invalid)" & vbNewLine)
                                End If
                            End If
                            '
                            If TextBox_Download_64_Bit_2.TextLength > 0 Then
                                If TextBox_Download_64_Bit_2.Text.Contains("://") Then
                                    If TextBox_Download_64_Bit_2.Text.StartsWith("http://") Or TextBox_Download_64_Bit_2.Text.StartsWith("https://") Then
                                        Request = WebRequest.Create(TextBox_Download_64_Bit_2.Text)
                                        Request.Proxy = Nothing
                                        'If required by the server, set the credentials.
                                        Request.Credentials = CredentialCache.DefaultCredentials
                                        Request.Timeout = 14000
                                        Response = Request.GetResponse
                                        Response.Close()
                                        If Not TextBox_File_Size_64_Bit_2.Text = File_Size_64 Then
                                            Scan.TextBox_Files.AppendText(ListBox_Operating_Systems_2.SelectedItem.ToString & " (File Size Changed)" & vbNewLine)
                                        End If

                                    End If
                                Else
                                    Scan.TextBox_Files.AppendText(ListBox_Operating_Systems_2.SelectedItem.ToString & " (Download 64 Bit URL invalid)" & vbNewLine)
                                End If
                            End If
                        End If
                        If Not Scan.TextBox_Files.Lines.Count = 1 Then
                            Scan.Text = Scan.Text & ", Results: " & Scan.TextBox_Files.Lines.Count
                        Else
                            Scan.Text = Scan.Text & ", Results: " & Scan.TextBox_Files.Lines.Count - 1
                        End If
                    Catch Wx As System.Net.WebException
                        Scan.TextBox_Files.AppendText(ListBox_Operating_Systems_2.SelectedItem.ToString & " (" & Wx.Message & ")" & vbNewLine)
                    Catch Ex As Exception
                        Scan.TextBox_Files.AppendText(ListBox_Operating_Systems_2.SelectedItem.ToString & " (" & Ex.Message & ")" & vbNewLine)
                    End Try
                Next
                Me.Show()
                Scan.Show()
                NotifyIcon_Main.Visible = True
                severdebuger = 1
            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub
    'Show Form1
    Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
        If severdebuger = 1 Then
            Scan.Show()
        End If
    End Sub
    '
    'ToolStripMenuItem
    '
    'Show/Hide HTML
    Private Sub ShowHTMLToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowHTMLToolStripMenuItem.Click
        If HTML.Visible = False Then
            HTML.Show()
        Else
            HTML.Hide()
        End If
    End Sub
    'Write OSL.cfg
    Private Sub WriteOSLcfgToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WriteOSLcfgToolStripMenuItem.Click
        Data.Write_OSL_cfg()
    End Sub
    'Exit
    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()
    End Sub
    '
    'TabPage Entered
    '
    'Enter Add OS TabPage
    Private Sub TabPage_Add_OS_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabPage_Add_OS.Enter
        Me.Height = 475
        Me.Width = 700
    End Sub
    'Enter Remove OS TabPage
    Private Sub TabPage_Remove_OS_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabPage_Remove_OS.Enter
        Me.Height = 268
        Me.Width = 360
    End Sub
    'Enter Edit OS TabPage
    Private Sub TabPage_Edit_OS_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabPage_Edit_OS.Enter
        Me.Height = 435
        Me.Width = 935
    End Sub
    'ScanServersToolStripMenuItem_Click
    Private Sub ScanServersToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ScanServersToolStripMenuItem.Click
        Try
            If Not Scan.Visible Then

                If Not TabPage_Remove_OS.Focus Then
                    TabPage_Remove_OS.Select()
                End If

                Me.Hide()
                severdebuger = 0
                NotifyIcon1.Visible = True
                NotifyIcon_Main.Visible = False
                For os As Integer = 0 To ListBox_Operating_Systems_2.Items.Count - 1
                    ListBox_Operating_Systems_2.SetSelected(os, True)
                    Scan.Text = "Scaned: " & os + 1 & "/" & ListBox_Operating_Systems_2.Items.Count & " Servers"
                    NotifyIcon1.BalloonTipText = "Scaned: " & os + 1 & "/" & ListBox_Operating_Systems_2.Items.Count & " Servers"
                    NotifyIcon1.ShowBalloonTip(14000)
                    Try
                        If TextBox_Download_32_Bit_2.TextLength > 0 Or TextBox_Download_64_Bit_2.TextLength > 0 Then
                            If TextBox_Download_32_Bit_2.TextLength > 0 Then
                                If TextBox_Download_32_Bit_2.Text.Contains("://") Then
                                    If TextBox_Download_32_Bit_2.Text.StartsWith("http://") Or TextBox_Download_32_Bit_2.Text.StartsWith("https://") Then
                                        Request = WebRequest.Create(TextBox_Download_32_Bit_2.Text)
                                        Request.Proxy = Nothing
                                        'If required by the server, set the credentials.
                                        Request.Credentials = CredentialCache.DefaultCredentials
                                        Request.Timeout = 14000
                                        Response = Request.GetResponse
                                        Response.Close()
                                        If Not TextBox_File_Size_32_Bit_2.Text = File_Size_32 Then
                                            Scan.TextBox_Files.AppendText(ListBox_Operating_Systems_2.SelectedItem.ToString & " (File Size Changed)" & vbNewLine)
                                        End If

                                    End If
                                Else
                                    Scan.TextBox_Files.AppendText(ListBox_Operating_Systems_2.SelectedItem.ToString & " (Download 32 Bit URL invalid)" & vbNewLine)
                                End If
                            End If
                            '
                            If TextBox_Download_64_Bit_2.TextLength > 0 Then
                                If TextBox_Download_64_Bit_2.Text.Contains("://") Then
                                    If TextBox_Download_64_Bit_2.Text.StartsWith("http://") Or TextBox_Download_64_Bit_2.Text.StartsWith("https://") Then
                                        Request = WebRequest.Create(TextBox_Download_64_Bit_2.Text)
                                        Request.Proxy = Nothing
                                        'If required by the server, set the credentials.
                                        Request.Credentials = CredentialCache.DefaultCredentials
                                        Request.Timeout = 14000
                                        Response = Request.GetResponse
                                        Response.Close()
                                        If Not TextBox_File_Size_64_Bit_2.Text = File_Size_64 Then
                                            Scan.TextBox_Files.AppendText(ListBox_Operating_Systems_2.SelectedItem.ToString & " (File Size Changed)" & vbNewLine)
                                        End If

                                    End If
                                Else
                                    Scan.TextBox_Files.AppendText(ListBox_Operating_Systems_2.SelectedItem.ToString & " (Download 64 Bit URL invalid)" & vbNewLine)
                                End If
                            End If
                        End If
                        If Not Scan.TextBox_Files.Lines.Count = 1 Then
                            Scan.Text = Scan.Text & ", Results: " & Scan.TextBox_Files.Lines.Count
                        Else
                            Scan.Text = Scan.Text & ", Results: " & Scan.TextBox_Files.Lines.Count - 1
                        End If
                    Catch Wx As System.Net.WebException
                        Scan.TextBox_Files.AppendText(ListBox_Operating_Systems_2.SelectedItem.ToString & " (" & Wx.Message & ")" & vbNewLine)
                    Catch Ex As Exception
                        Scan.TextBox_Files.AppendText(ListBox_Operating_Systems_2.SelectedItem.ToString & " (" & Ex.Message & ")" & vbNewLine)
                    End Try
                Next
                Me.Show()
                Scan.Show()
                NotifyIcon_Main.Visible = True
                severdebuger = 1
            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub
    'Search For OS
    Private Sub TextBox_Search_For_OS_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox_Search_For_OS.KeyDown
        Try
            If e.KeyData = Keys.Enter Then
                If TextBox_Search_For_OS.Text.Length > 0 Then
                    NotifyIcon_Main.BalloonTipText = "Searching for Operating System."
                    NotifyIcon_Main.ShowBalloonTip(1500)
                    NotifyIcon_Main.BalloonTipText = Nothing
                    Dim ListBox_item As String
                    For Each ListBox_item In ListBox_Operating_Systems_2.Items
                        If ListBox_item.ToLower = TextBox_Search_For_OS.Text.ToLower Then
                            ListBox_Operating_Systems_2.SelectedItem = ListBox_item
                            ListBox_Operating_Systems_2.Select()
                            NotifyIcon_Main.BalloonTipText = "Operating System found."
                            NotifyIcon_Main.ShowBalloonTip(1500)
                            NotifyIcon_Main.BalloonTipText = Nothing
                            TextBox_Search_For_OS.Clear()
                            Exit Sub
                        End If
                    Next
                    'Show message OS found
                    NotifyIcon_Main.BalloonTipText = "Operating System not found."
                    NotifyIcon_Main.ShowBalloonTip(1500)
                    NotifyIcon_Main.BalloonTipText = Nothing
                    TextBox_Search_For_OS.Clear()
                End If
            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub
End Class